/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller.administration;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Enseignant;

/**
 *
 * @author Paul
 */
public class AdministrationAccueil extends HttpServlet {
    public static final String VUE_CONNEXION = "view/connexion.jsp";
    public static final String VUE_ADMINISTRATION_ACCUEIL = "/WEB-INF/administration/administrationAccueil.jsp";

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Enseignant ens = (Enseignant) request.getSession().getAttribute("enseignant");
        if (ens != null) {
            this.getServletContext().getRequestDispatcher(VUE_ADMINISTRATION_ACCUEIL).forward(request, response);
        } else {
            request.getRequestDispatcher(VUE_CONNEXION).forward(request, response);
        }
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Enseignant ens = (Enseignant) request.getSession().getAttribute("enseignant");
        if (ens != null) {
            this.getServletContext().getRequestDispatcher(VUE_ADMINISTRATION_ACCUEIL).forward(request, response);
        } else {
            request.getRequestDispatcher(VUE_CONNEXION).forward(request, response);
        }
    }
}
